﻿Imports Phila
Imports Phila.Sql
Imports Phila.CommonClasses

Public Class Login
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Dim txtarr As Array
        Dim strPass As String = Encryptdata(txtPassword.Text)
        'txtarr = RetriveData2("exec AdminLogin '" & Server.HtmlEncode(txtUserName.Text) & "','" & Server.HtmlEncode(txtPassword.Text) & "'", 1)
        txtarr = RetriveData("select Id, Username from ptn_Users where Username='" & Server.HtmlEncode(txtUserName.Text) & "' and Password='" & strPass & "' and IsAdmin=1", 1)
        If Not txtarr(0) Is Nothing Then
            'Response.Cookies("Admin").Values("UserID") = Convert.ToString(txtarr(0))
            'Response.Cookies("Admin").Values("Username") = Convert.ToString(txtarr(1))
            'Response.Cookies("Admin").Expires = System.DateTime.Now.AddMinutes(60)
            Session.Item("UserID") = txtarr(0)
            Session.Item("UserName") = txtarr(1)
            Response.Redirect("Default.aspx")
            'Response.Write(Session.Item("UserID") & " ok ")
        End If
        'Dim Results As Integer = 0

        'If txtUserName.Text <> String.Empty AndAlso txtPassword.Text <> String.Empty Then

        '    Results = AdminLogin(txtUserName.Text.Trim, txtPassword.Text.Trim)
        '    If Results = 1 Then
        '        Response.Redirect("Default.aspx")
        '    Else
        '        Exit Sub
        '    End If
        'Else
        'End If

    End Sub

End Class